<!--回弹业务数据字典---回弹仪器设备管理---查看-->
<template>
  <div class="department" id="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group
            v-model="radio"
            size="small"
            @change="modelType($event)"
          >
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
            <!-- #2b5a9d -->
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button
              type="primary"
              icon="el-icon-refresh"
              size="small"
              @click="yj_searchForm(getList)"
            ></el-button>
            <el-button
              type="primary"
              icon="el-icon-circle-plus-outline"
              size="small"
              v-if="getList.modelType == '0' && yj_add == true"
              @click="edit('新增')"
              >新增</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
              v-if="getList.modelType == '0' && yj_edit == true"
              @click="edit('编辑')"
              >编辑</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-circle-check"
              size="small"
              v-if="getList.modelType == '0' && yj_submit == true"
              @click="SubmitText(fId)"
              >提交</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-document-checked"
              size="small"
              v-if="getList.modelType == '0' && yj_aduit == true"
              @click="edit('审核')"
              >审核</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-delete"
              size="small"
              v-if="getList.modelType == '0' && yj_delete == true"
              @click="rowDelete(fId)"
              >删除</el-button
            >
          </div>
        </div>
      </div>

      <!-- 表格 -->
      <div class="text_table">
        <tableData
          :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'"
          :config="table_config"
          :dataList="tableData"
          :loading="loading"
          @selection-change="selectionChange"
          @sort-change="sortChange"
          @click-change="rowChange"
          @ClickOnLine="yj_viewForm"
          :page="getList.page"
          :pageSize="getList.pageSize"
        />
        <pagination
          v-if="navigatepageNums > 1"
          :info="queryCriteriaData"
          :treelength="treelength"
          :total="queryCriteriaData.total"
          :pageNum.sync="getList.page"
          :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)"
        />
      </div>
      <!--配合比通知单编号弹框 查看 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible"
          v-loading="loadingEditDialog"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div style="overflow-y: auto; margin-bottom: 20px">
              <div class="baseTitle">场站质量管理网格</div>
              <div class="publicForm" style="height: 80px">
                <publicForm
                  ref="publicForm0"
                  lableWidth="95px"
                  :formObj="formObjShow"
                  :formData="formData"
                  @selectChange="selectChange"
                  @inputChange="inputChange"
                  @inputFocus="inputFocus"
                >
                </publicForm>
              </div>

              <div
                style="
                  width: 100%;
                  display: flex;
                  justify-content: space-between;
                "
              >
                <div style="width: 50%">
                  <div class="baseTitle">项目部质量责任人</div>
                  <div class="publicForm" style="height: 170px">
                    <publicForm
                      ref="publicForm1"
                      lableWidth="95px"
                      :formObj="projectShow"
                      :formData="formData"
                      @selectChange="selectChange"
                      @inputChange="inputChange"
                      @inputFocus="inputFocus"
                    >
                    </publicForm>
                  </div>
                </div>
                <div style="width: 50%">
                  <div class="baseTitle">监理质量责任人</div>
                  <div class="publicForm" style="height: 170px">
                    <publicForm
                      ref="publicForm2"
                      lableWidth="95px"
                      :formObj="supervisionShow"
                      :formData="formData"
                      @selectChange="selectChange"
                      @inputChange="inputChange"
                      @inputFocus="inputFocus"
                    >
                    </publicForm>
                  </div>
                </div>
              </div>

              <div class="baseTitle" v-if="Sign == '审核' || Sign == '查看'">
                总工审核
              </div>
              <div
                class="publicForm"
                v-if="Sign == '审核' || Sign == '查看'"
                style="height: 80px"
              >
                <publicForm
                  ref="publicForm3"
                  lableWidth="95px"
                  :formObj="examineShow"
                  :formData="formData"
                  @selectChange="selectChange"
                  @inputChange="inputChange"
                  @inputFocus="inputFocus"
                >
                </publicForm>
              </div>
              <div style="height: 50px"></div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button
              type="primary"
              v-if="Sign != '审核'"
              @click="yj_saveForm(0)"
              >保存</el-button
            >
            <el-button type="primary" v-else @click="yj_saveForm(1)"
              >审核保存</el-button
            >
            <el-button type="warning" @click="dialogEditVisible = false"
              >关闭</el-button
            >
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getQualityDutyStationLists, //列表
  getQualityDutyStationByFid, //详情
  saveQualityDutyStation, //保存
  deleteQualityDutyStation, //删除
  commitQualityDutyStation, //提交
  aduitQualityDutyStation, //总工审核接口
  getBaseDepartmentUser, //调人员
} from "@/api/request.js";
import TableData from "@/components/stationProductionPage/HntManage/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项

export default {
  inject: ["reload"],
  name: "stationQualityListText",
  data() {
    return {
      name: "stationQualityListText",
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      // 分页
      // yj_view: null,
      yj_add: null,
      yj_edit: null,
      yj_delete: null,
      yj_submit: null,
      yj_aduit: null,
      radio: "待办",
      // 列表
      getList: {
        fCompanyid: "", // 查询条件项目名称id
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "0", // 0-待办 1-已办 传2 表示列表页查询
        fQualitygridtype: "", // 上方查询条件工程网格
        fQualitygridclass: "", // 上方查询条件质量网格
        keyWord: "", // 责任人
      },
      fId: null, //当前行数据fId
      loading: false, //列表转载
      table_config: formJs.table_configText,
      tableData: [], //表格列表数据列表
      // 列表

      // 弹框
      timeYMD: null, //当前日期
      btnShow: true,
      dialogTitle: "",
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示

      // 陈妮娜
      formObjShow: null, //场站质量管理网格
      formObj: formJs.formObj,
      formObjLook: formJs.formObjLook,
      supervisionShow: null, //页面展示
      supervision: formJs.supervision, //责任人右侧--编辑
      supervisionLook: formJs.supervisionLook, //责任人右侧--查看
      projectShow: null,
      project: formJs.project, //责任人左侧--编辑
      projectLook: formJs.projectLook, //责任人左侧--查看
      examineShow: null, //总工审核
      examine: formJs.examine, //总工审核--编辑
      examineLook: formJs.examineLook, //总工审核--查看
      Sign: "",
      supervisionUserList: [], //监理用户列表初始值
      projectUsersList: [], //项目部列表初始值
      // 陈妮娜

      formData: formJs.formData,
      saveData: null,

      // 弹框

      userInfo: {}, //登录用户
    };
  },
  components: {
    TableData, //主页面列表
    Pagination, //分页
    publicForm, //表单
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
    console.log("userInfo", this.userInfo);
  },
  mounted() {
    this.getList = {
      fCompanyid: "", // 查询条件项目名称id
      page: 1, // 当前页码
      pageSize: 20, // 每页显示条数
      userId: this.userInfo.userId, // 查询待办或已办时传 列表页查询不传
      modelType: "0", // 0-待办 1-已办 传2 表示列表页查询
      fQualitygridtype: "", // 质量网格类别
      fQualitygridclass: "", // 上方查询条件质量网格
      keyWord: "", // 责任人
    };
    this.getHeight();
    this.getData();
    this.yj_searchForm(this.getList);
    this.btnRole(this.name);
    this.getProjectUserList(this.userInfo.companyId);
    this.getSupervisionUser(this.userInfo.jlCompanyId);
    this.table_config.operation.cols = [
      {
        prop: "fStatus",
        type: "primary",
        handleRow: this.handleRow,
      },
    ];
    this.table_config.operation["specialClass"] = function (rowData) {
      var color = null;
      if (rowData == "未提交") {
        color = "red !important";
      } else if (rowData == "已完成") {
        //  {
        //   color = "#409eff !important";
        // } else if (rowData == "运输中") {
        //   color = "#e6a23c  !important";
        // }
        color = "green !important";
      }
      return color;
    };
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("yjSmart-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        // this.yj_view = btnStr.includes("yj_view");
        this.yj_add = btnStr.includes("yj_add");
        this.yj_edit = btnStr.includes("yj_edit");
        this.yj_delete = btnStr.includes("yj_delete");
        this.yj_submit = btnStr.includes("yj_submit");
        this.yj_aduit = btnStr.includes("yj_aduit");
      } else {
        // this.yj_view = true;
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        this.yj_submit = true;
        this.yj_aduit = true;
      }
    },

    modelType(e) {
      this.fId = "";
      this.row = "";
      if (e == "待办") {
        this.getList.modelType = "0";
        this.getList.userId = this.userInfo.userId;
      } else {
        this.getList.modelType = "1";
        this.getList.userId = this.userInfo.userId;
      }
      this.yj_searchForm(this.getList);
    },
    // 获取列表数据
    yj_searchForm(id) {
      this.loading = true;
      getQualityDutyStationLists(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.pageInfo.list;
            that.queryCriteriaData = res.data.pageInfo;
            that.navigatepageNums =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("列表");
          this.loading = false;
        });
    },

    edit(titel) {
      this.dialogTitle = titel;
      this.Sign = titel;
      this.formObjShow = this.formObj;
      this.supervisionShow = this.supervision;
      this.projectShow = this.project;
      this.btnShow = true;
      if (titel == "新增") {
        this.dialogEditVisible = true;
        this.formData = {
          fId: "",
          fProjectname: this.userInfo.projectName, // 当前登录人项目名称
          fProjectid: this.userInfo.projectId, // 当前登录人项目ID
          fCompanyname: this.userInfo.companyName, // 当前登录人标段名称
          fCompanyid: this.userInfo.companyId, // 当前登录人标段ID

          fQualitygridtype: "", //工程网格类别
          fQualitygridclass: "", //质量网格类别
          fProjectposition: "", //工程部位
          fSgusername: "", //施工负责人
          fSguserid: "", //施工负责人id
          fSgusermobile: "", //施工负责人电话

          fCheckusername: "", //现场质检员
          fCheckuserid: "", //现场质检员id
          fCheckusermobile: "", //现场质检员电话

          fTestusername: "", //试验员
          fTestuserid: "", //试验员id
          fTestusermobile: "", //试验员电话

          fScenesupervisor: "", //驻地监理
          fScenesupervisorid: "", //驻地监理id
          fScenesupervisormobile: "", //驻地监理电话

          fStationsupervisor: "", //现场监理员
          fStationsupervisorid: "", //现场监理员id
          fStationsupervisormobile: "", //现场监理员电话

          fTestsupervisor: "", //试验监理
          fTestsupervisorid: "", //试验监理id
          fTestsupervisormobile: "", //试验监理电话
          // userId: this.userInfo.userId, //当前登录人id
          // userName: this.userInfo.realName, // 当前登录人名称
          fReportuserid: this.userInfo.userId, //填报人id
          fReportusername: this.userInfo.realName, //填报人
          fReportdates: this.timeYMD, //填报日期
          fSubmitengineerid: "", //提交项目总工id
          fSubmitengineer: "", //提交项目总工

          fAduitresult: "", //审核意见
          fAduitmessage: "", //意见说明
          fAduitdates: "", //审核日期
          fEngineerid: "", //项目总工id
          fEngineer: "", //项目总工

          fIswork: "", //是否开工
          fWorkdates: "", //生产/施工开始时间
          fWorkreportdates: "", //填报日期
          fWorkreportuserid: "", //填报人id
          fWorkreportusername: "", //填报人
        };
      } else if (titel == "编辑") {
        if (this.fId != "" && this.fId != null) {
          if (this.row.fStatus == "编辑中" || this.row.fStatus == "被退回") {
            this.loadingEditDialog = true; //弹框loading
            this.dialogEditVisible = true;
            this.getConcrete(this.fId);
          } else {
            return this.$message.error("本条数据不可编辑");
          }
        } else {
          return this.$message.error("请先选择需要编辑的数据");
        }
      } else if (titel == "审核") {
        if (this.fId != "" && this.fId != null) {
          if (this.row.fStatus == "审核中") {
            this.formObjShow = this.formObjLook;
            this.supervisionShow = this.supervisionLook;
            this.projectShow = this.projectLook;
            this.examineShow = this.examine;
            this.loadingEditDialog = true; //弹框loading
            this.dialogEditVisible = true;
            this.getConcrete(this.fId);
          } else {
            return this.$message.error("请选择信息状态为‘审核中’的数据");
          }
        } else {
          return this.$message.error("请先选择需要审核的数据");
        }
      }
    },
    // 获取详情
    getConcrete(id) {
      getQualityDutyStationByFid({ fId: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false; //弹框loading
            this.formData = res.data.yjQmpMsQualitydutystationManagement;
            if (this.Sign == "编辑") {
              //填报人
              if (
                this.formData.fReportusername == "" ||
                this.formData.fReportusername == null ||
                this.formData.fReportuserid == "" ||
                this.formData.fReportuserid == null
              ) {
                this.formData.fReportusername = this.userInfo.realName;
                this.formData.fReportuserid = this.userInfo.userId;
              }
              //填报日期
              if (
                this.formData.fReportdates == "" ||
                this.formData.fReportdates == null
              ) {
                this.formData.fReportdates = this.timeYMD;
              }
            } else if (this.Sign == "审核") {
              // 审核意见
              if (
                this.formData.fAduitresult == "" ||
                this.formData.fAduitresult == null
              ) {
                this.formData.fAduitresult = "情况属实。";
              }
              //审核日期
              if (
                this.formData.fAduitdates == "" ||
                this.formData.fAduitdates == null
              ) {
                this.formData.fAduitdates = this.timeYMD;
              }
              //项目总工
              if (
                this.formData.fEngineer == "" ||
                this.formData.fEngineer == null ||
                this.formData.fEngineerid == "" ||
                this.formData.fEngineerid == null
              ) {
                this.formData.fEngineer = this.userInfo.realName;
                this.formData.fEngineerid = this.userInfo.userId;
              }
            }
          } else {
            console.log("详情接口", res.errcode);
          }
        })
        .catch((err) => {
          console.log(err.msg);
        });
    },
    // 保存
    yj_saveForm(num) {
      this.fId = "";
      if (num == 0) {
        if (this.$refs.publicForm0.submitForm()) {
          if (this.$refs.publicForm1.submitForm()) {
            if (this.$refs.publicForm2.submitForm()) {
              this.saveData = {
                fId: this.formData.fId,
                userId: this.userInfo.userId,
                userName: this.userInfo.realName,
                fProjectname: this.formData.fProjectname,
                fProjectid: this.formData.fProjectid,
                fCompanyname: this.formData.fCompanyname,
                fCompanyid: this.formData.fCompanyid,

                fQualitygridtype: this.formData.fQualitygridtype, //工程网格类别
                fQualitygridclass: this.formData.fQualitygridclass, //质量网格类别
                fProjectposition: this.formData.fProjectposition, //工程部位

                fSgusername: this.formData.fSgusername, //施工负责人
                fSguserid: this.formData.fSguserid, //施工负责人id
                fSgusermobile: this.formData.fSgusermobile, //施工负责人电话

                fCheckusername: this.formData.fCheckusername, //现场质检员
                fCheckuserid: this.formData.fCheckuserid, //现场质检员id
                fCheckusermobile: this.formData.fCheckusermobile, //现场质检员电话

                fTestusername: this.formData.fTestusername, //试验员
                fTestuserid: this.formData.fTestuserid, //试验员id
                fTestusermobile: this.formData.fTestusermobile, //试验员电话

                fScenesupervisor: this.formData.fScenesupervisor, //驻地监理
                fScenesupervisorid: this.formData.fScenesupervisorid, //驻地监理id
                fScenesupervisormobile: this.formData.fScenesupervisormobile, //驻地监理电话

                fStationsupervisor: this.formData.fStationsupervisor, //现场监理员
                fStationsupervisorid: this.formData.fStationsupervisorid, //现场监理员id
                fStationsupervisormobile:
                  this.formData.fStationsupervisormobile, //现场监理员电话

                fTestsupervisor: this.formData.fTestsupervisor, //试验监理
                fTestsupervisorid: this.formData.fTestsupervisorid, //试验监理id
                fTestsupervisormobile: this.formData.fTestsupervisormobile, //试验监理电话

                fReportuserid: this.formData.fReportuserid, //填报人id
                fReportusername: this.formData.fReportusername, //填报人
                fReportdates: this.formData.fReportdates, //填报日期
                fSubmitengineerid: this.formData.fSubmitengineerid, //提交项目总工id
                fSubmitengineer: this.formData.fSubmitengineer, //提交项目总工
              };
              saveQualityDutyStation(this.saveData)
                .then((res) => {
                  if (res.errcode == 0) {
                    this.yj_searchForm(this.getList);
                    this.dialogEditVisible = false;
                    this.$message.success("新增成功");
                  } else {
                    this.$message.error(res.msg);
                    console.log("接口报错");
                  }
                })
                .catch((error) => {
                  console.log(error);
                });
            } else {
              console.log("error");
            }
          } else {
            console.log("error");
          }
        } else {
          console.log("error");
        }
      } else if (num == 1) {
        if (this.$refs.publicForm2.submitForm()) {
          var saveData1 = {
            fId: this.formData.fId, //传入表示修改 不传表示新增
            userId: this.userInfo.userId, //当前登录人id
            userName: this.userInfo.realName, // 当前登录人名称
            fProjectname: this.formData.fProjectname, // 当前登录人项目名称
            fProjectid: this.formData.fProjectid, // 当前登录人项目ID
            fCompanyname: this.formData.fCompanyname, // 当前登录人标段名称
            fCompanyid: this.formData.fCompanyid, // 当前登录人标段ID
            fAduitresult: this.formData.fAduitresult, //审核意见
            fAduitmessage: this.formData.fAduitmessage, //意见说明
            fAduitdates: this.formData.fAduitdates, //审核日期
            fEngineerid: this.formData.fEngineerid, //项目总工id
            fEngineer: this.formData.fEngineer, //项目总工
          };
          aduitQualityDutyStation(saveData1)
            .then((res) => {
              if (res.errcode == 0) {
                this.yj_searchForm(this.getList);
                this.dialogEditVisible = false;
                this.$message.success("新增成功");
              } else {
                this.$message.error(res.msg);
                console.log("接口报错");
              }
            })
            .catch((error) => {
              console.log(error);
            });
        } else {
          console.log("error");
        }
      }
    },

    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        if (this.row.fStatus == "编辑中") {
          if (this.row.fReportdates === this.timeYMD) {
            this.$confirm("是否继续提交?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            })
              .then(() => {
                this.loading = true;
                commitQualityDutyStation({
                  fId: id,
                  userId: this.userInfo.userId,
                  userName: this.userInfo.realName,
                })
                  .then((res) => {
                    if (res.errcode == 0) {
                      this.loading = false;
                      this.yj_searchForm(this.getList);
                      this.$message.success("提交成功");
                    } else {
                      this.$message.error("提交失败", res.msg);
                      this.loading = false;
                    }
                  })
                  .catch(() => {
                    console.log("提交失败");
                    this.loading = false;
                  });
              })
              .catch(() => {
                this.$message.info("取消提交");
              });
          } else {
            return this.$message.error("请将填报日期改为当前日期");
          }
        } else {
          return this.$message.error("本条数据不可提交");
        }
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },

    // 删除
    rowDelete(id) {
      if (id != "" && id != null) {
        if (this.row.fStatus == "编辑中") {
          this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.loading = true;
              deleteQualityDutyStation({ fId: id })
                .then((res) => {
                  if (res.errcode == 0) {
                    this.loading = false;
                    this.yj_searchForm(this.getList);
                    this.$message.success("删除成功");
                  } else {
                    this.$message.error("删除失败", res.msg);
                    this.loading = false;
                  }
                })
                .catch(() => {
                  console.log("删除失败");
                  this.loading = false;
                });
            })
            .catch(() => {
              this.$message("取消删除");
            });
        } else {
          return this.$message.error("本条数据不可删除");
        }
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },

    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      this.dialogHeight = h * 0.36 + "px";
    },
    // 点击查看
    yj_viewForm(row, label) {
      this.fId = row.fId;
      if (label == "工程网格类别") {
        this.editText(this.fId);
      }
    },

    // 查看
    editText(id) {
      this.formObjShow = this.formObjLook;
      this.supervisionShow = this.supervisionLook;
      this.projectShow = this.projectLook;
      this.examineShow = this.examineLook;
      this.dialogTitle = "查看";
      this.Sign = "查看";
      this.btnShow = false;
      if (id != "" && id != null) {
        this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        getQualityDutyStationByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog = false; //弹框loading
              this.formData = res.data.yjQmpMsQualitydutystationManagement;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    // 调人员
    getProjectUserList(id) {
      this.projectUsersList = []; //项目部列表初始值

      var getProjectUserList = []; //监理用户列表过滤后
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            var getProjectUser = {
              value: "",
              label: "",
            };
            res.data.childList.map((v) => {
              if (v.personList != undefined) {
                v.personList.map((item) => {
                  this.projectUsersList.push(item);
                });
              }
            });

            this.projectUsersList.map((item) => {
              getProjectUser = {
                value: item.fRealname,
                label: item.fRealname,
              };
              getProjectUserList.push(getProjectUser);
            });
            // console.log("项目部", getProjectUserList);
            this.project[0].options = getProjectUserList;
            this.project[2].options = getProjectUserList;
            this.project[4].options = getProjectUserList;
            this.project[7].options = getProjectUserList;
          } else {
            this.$message.error(res.msg);
            console.log("部门管理-查询部门列表以及下属人员,接口报错");
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员", error.msg);
        });
    },
    getSupervisionUser(id) {
      this.supervisionUserList = []; //监理用户列表初始值
      var getSupervisionUserList = []; //监理用户列表过滤后
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            var getSupervisionUser = {
              value: "",
              label: "",
            };

            res.data.childList.map((v) => {
              if (v.personList != undefined) {
                v.personList.map((item) => {
                  this.supervisionUserList.push(item);
                });
              }
            });

            this.supervisionUserList.map((item) => {
              getSupervisionUser = {
                value: item.fRealname,
                label: item.fRealname,
              };
              getSupervisionUserList.push(getSupervisionUser);
            });
            // console.log("监理", getSupervisionUserList);
            this.supervision[0].options = getSupervisionUserList;
            this.supervision[2].options = getSupervisionUserList;
            this.supervision[4].options = getSupervisionUserList;
          } else {
            this.$message.error(res.msg);
            console.log("部门管理-查询部门列表以及下属人员,接口报错");
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员", error.msg);
        });
    },
    // 调人员
    selectChange(value, index, prop) {
      console.log("下拉变", value, index, prop);
      // 工程网格下拉框
      if (prop == "fQualitygridclass") {
        if (value == "生产场站质量网格") {
          this.formObjShow[1].options = [
            {
              value: "混凝土拌合站",
              label: "混凝土拌合站",
            },
            {
              value: "水稳料拌合站",
              label: "水稳料拌合站",
            },
            {
              value: "沥青料拌合站",
              label: "沥青料拌合站",
            },
            {
              value: "钢筋加工场",
              label: "钢筋加工场",
            },
            {
              value: "梁板预制场",
              label: "梁板预制场",
            },
            {
              value: "碎石材料加工厂",
              label: "碎石材料加工厂",
            },
            {
              value: "小型预制构件厂",
              label: "小型预制构件厂",
            },
          ];
        } else if (value == "工程实体质量网格") {
          this.formObjShow[1].options = [
            {
              value: "路基土石方",
              label: "路基土石方",
            },
            {
              value: "路面工程",
              label: "路面工程",
            },
            {
              value: "桥梁工程",
              label: "桥梁工程",
            },
            {
              value: "隧道工程",
              label: "隧道工程",
            },
            {
              value: "涵洞工程",
              label: "涵洞工程",
            },
            {
              value: "防护排水",
              label: "防护排水",
            },
            {
              value: "交安工程",
              label: "交安工程",
            },
            {
              value: "管道工程",
              label: "管道工程",
            },
            {
              value: "房建工程",
              label: "房建工程",
            },
            {
              value: "绿化工程",
              label: "绿化工程",
            },
          ];
        } else {
          this.formObjShow[1].options = [];
        }
      }

      // 施工负责人
      if (prop == "fSgusername") {
        console.log("projectUsersList", this.projectUsersList);
        for (let index = 0; index < this.projectUsersList.length; index++) {
          const element = this.projectUsersList[index];
          if (this.formData.fSgusername == element.fRealname) {
            this.formData.fSguserid = element.fUserid;
            this.formData.fSgusermobile = element.fMobile;
          }
        }
      }

      //现场质检员
      if (prop == "fCheckusername") {
        for (let index = 0; index < this.projectUsersList.length; index++) {
          const element = this.projectUsersList[index];
          if (this.formData.fCheckusername == element.fRealname) {
            this.formData.fCheckuserid = element.fUserid;
            this.formData.fCheckusermobile = element.fMobile;
          }
        }
      }

      //试验员
      if (prop == "fTestusername") {
        for (let index = 0; index < this.projectUsersList.length; index++) {
          const element = this.projectUsersList[index];
          if (this.formData.fTestusername == element.fRealname) {
            this.formData.fTestuserid = element.fUserid;
            this.formData.fTestusermobile = element.fMobile;
          }
        }
      }

      //提交项目总工
      if (prop == "fSubmitengineer") {
        for (let index = 0; index < this.projectUsersList.length; index++) {
          const element = this.projectUsersList[index];
          if (this.formData.fSubmitengineer == element.fRealname) {
            console.log("提交项目总工", element);
            this.formData.fSubmitengineerid = element.fUserid;
          }
        }
      }
      console.log(
        9999,
        this.formData.fSubmitengineer,
        this.formData.fSubmitengineerid
      );
      //驻地监理
      if (prop == "fScenesupervisor") {
        for (let index = 0; index < this.supervisionUserList.length; index++) {
          const element = this.supervisionUserList[index];
          if (this.formData.fScenesupervisor == element.fRealname) {
            this.formData.fScenesupervisorid = element.fUserid;
            this.formData.fScenesupervisormobile = element.fMobile;
          }
        }
      }

      //现场监理员
      if (prop == "fStationsupervisor") {
        for (let index = 0; index < this.supervisionUserList.length; index++) {
          const element = this.supervisionUserList[index];
          if (this.formData.fStationsupervisor == element.fRealname) {
            this.formData.fStationsupervisorid = element.fUserid;
            this.formData.fStationsupervisormobile = element.fMobile;
          }
        }
      }

      //试验监理
      if (prop == "fTestsupervisor") {
        for (let index = 0; index < this.supervisionUserList.length; index++) {
          const element = this.supervisionUserList[index];
          if (this.formData.fTestsupervisor == element.fRealname) {
            this.formData.fTestsupervisorid = element.fUserid;
            this.formData.fTestsupervisormobile = element.fMobile;
          }
        }
      }
    },
    inputChange(value, index, prop) {
      console.log("input变", value, index, prop);
    },
    inputFocus(index, prop) {
      console.log("input获焦", index, prop);
    },
    getData() {
      var time = new Date();
      const y = time.getFullYear();
      const m = (time.getMonth() + 1 + "").padStart(2, "0");
      const d = (time.getDate() + "").padStart(2, "0");
      this.timeYMD = `${y}-${m}-${d}`;
    },
    // 点击当前
    rowChange(val) {
      this.row = val;
      this.fId = val.fId;
    },
    // 多选方法
    selectionChange() {},
    // 排序方法
    sortChange() {},
  },
};
</script>

<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}
/* 弹框 */

.mouldForm /deep/ .el-col-12 .el-form-item:first-child .el-input__suffix {
  left: 84% !important;
}
.publicForm .mouldForm /deep/ .el-form-item__content {
  margin-left: 105px !important;
}
/* 弹框 */
</style>